public class GuiReadThread extends Thread
{
	SocketClient socket;
	String msg;
	Gui gui;
	String[] msgTable;
	String lastMsg;
	GuiReadThread(SocketClient s,Gui gui)
	{
		this.socket=s;
		this.gui=gui;
	}
	public void run()
	{
		while(!isInterrupted())
		{
			try 
			{
				GuiReadThread.sleep(200);
			} 
			catch (InterruptedException e) 
			{				
				//e.printStackTrace();
			}
			if(socket.connected==true)
			{
				String clientCommand = "";
				clientCommand = socket.msg.msg;
				
				if(clientCommand!=null)
				{
	            	msgTable=clientCommand.split(":");
	            	if(msgTable[0].equalsIgnoreCase("C"))
	            	{
	            		gui.bCard1.setText(msgTable[1]);
	            		gui.bCard2.setText(msgTable[2]);
	            		gui.bCard3.setText(msgTable[3]);
	            		gui.bCard4.setText(msgTable[4]);
	            	}	
	            	else if(msgTable[0].equalsIgnoreCase("M"))
	            	{
	            		if(!(msgTable[1].equalsIgnoreCase(lastMsg)))
	            		{	
	            			if(!(msgTable[1].equalsIgnoreCase("FALSE") || msgTable[1].equalsIgnoreCase("TRUE")))
	            			{
	            				gui.taMsg.setText(gui.taMsg.getText()+"\n"+msgTable[1]);
	            				lastMsg=msgTable[1];
	            			}
	            		}	            		
	            	}
	            	else if(msgTable[0].equalsIgnoreCase("B"))
	            	{
	            		gui.tfBankRoll.setText(msgTable[1]);
	            	}
				}
			}
		}
	}

}
